﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using DBMigrator.Core.DbObjects;
using DBMigrator.Core.DbObjects.Column;
using DBMigrator.Core.DbObjects.Data.Select;
using DBMigrator.Core.DbObjects.Data.Update;
using DBMigrator.Core.DbObjects.Data.What;
using DBMigrator.Core.DbObjects.Data.Where;
using DBMigrator.Core.DbObjects.Table;

namespace DBMigrator.Core.DBProviders
{
    public interface IProvider : IDisposable
    {
        void Initialize(string connectionString);
        bool DoesTableExist(string tableName);
        void CreateTable(string tableName, Action<ICreateTable> tableSetup);
        void CreateTableWithPrimaryKey(string tableName, string primaryKeyName, Action<ICreateTable> tableSetup);
        void CreateTableWithPrimaryKey<TPrimaryKey>(string tableName, string primaryKeyName, Action<ICreateTable> tableSetup);
        void AlterTable(string tableName, Action<IAlterTable> alterations);
        void DropTable(string tableName);
        IDataReader Select(Action<IWhat> what, Action<IFrom> from, Action<IWhere> where);
        IDataReader Select(Action<IWhat> what, Action<IFrom> from);
        IDataReader SelectAllFrom(Action<IFrom> from, Action<IWhere> where);
        IDataReader SelectAllFrom(Action<IFrom> from);
        IDataReader SelectAllFrom(string tableName, Action<IWhere> where);
        IDataReader SelectAllFrom(string tableName);
        int SelectCountFrom(string whatToCount, Action<IFrom> from, Action<IWhere> where);
        int SelectCountFrom(string whatToCount, Action<IFrom> from);
        int SelectCountFrom(string whatToCount, string tableName, Action<IWhere> where);
        int SelectCountFrom(string whatToCount, string tableName);
        int DeleteFrom(string tableName, Action<IWhere> where);
        int DeleteAllFrom(string tableName);
        int InsertInto<T>(string tableName, IEnumerable<T> values);
        int InsertInto<T>(string tableName, T value);
        int Update(string tableName, Action<ISet> set, Action<IWhere> where);
        int Update(string tableName, Action<ISet> set);
        int ExecuteNonQuery(string sql);
        IDataReader ExecuteQuery(string sql);
        T ExecuteScalar<T>(string sql);
    }
}
